package cn.throwx.sc.ch2;

import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;

/**
 * @author throwable
 * @version v1
 * @description Pbkdf2PasswordEncoder demo
 * @since 2021/10/30 17:50
 */
public class Pbkdf2PasswordEncoderDemo {

    private static final String RAW_PD = "throwable";
    private static final String SECRET = "12345678";

    public static void main(String[] args) {
        PasswordEncoder passwordEncoder = new Pbkdf2PasswordEncoder(SECRET);
        String encodedPassword = passwordEncoder.encode(RAW_PD);
        System.out.printf("[pbkdf2]raw:%s,encoded:%s,match:%s\n", RAW_PD, encodedPassword,
                passwordEncoder.matches(RAW_PD, encodedPassword));
    }
}
